import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/config/lf_type_config.dart';
import 'package:largefriends/entity/entities/lf_user_entity.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_fonts.dart';
import 'package:largefriends/res/lf_text_style.dart';
import 'package:largefriends/res/strings/lf_strings.dart';
import 'package:largefriends/widgets/category_widget.dart';

class LfUserDetailWidget extends StatelessWidget {
  const LfUserDetailWidget({super.key, required this.userEntity});
  final LfUserEntity userEntity;
  @override
  Widget build(BuildContext context) {
    return LfCategoryWidget(
      title: strDetails.tr,
      child: Column(
        children: [
          _baseInfoItem(
            label: strGender.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.gender,
              userEntity.gender,
            ),
          ),
          _baseInfoItem(
            label: strRelationship.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.relationship,
              userEntity.marital,
            ),
          ),
          _baseInfoItem(
            label: strHeight.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.height,
              userEntity.height,
            ),
          ),
          _baseInfoItem(
            label: strBodyType.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.body,
              userEntity.body,
            ),
          ),
          _baseInfoItem(
            label: strEthnicity.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.ethnicity,
              userEntity.ethnicity,
            ),
          ),
          _baseInfoItem(
            label: strReligion.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.religion,
              userEntity.religion,
            ),
          ),
          _baseInfoItem(
            label: strLanguages.tr,
            value: TypeConfig().getValueByKey(
              LfConfigTypeEnum.language,
              userEntity.language,
            ),
          ),
        ],
      ),
    );
  }
}

Widget _baseInfoItem({required String label, required String value}) {
  return Container(
    padding: EdgeInsets.only(top: 6.h, bottom: 1.h),
    margin: EdgeInsets.symmetric(vertical: 3.h),
    decoration: BoxDecoration(
      border: Border(bottom: BorderSide(color: color210215)),
    ),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Container(
          padding: EdgeInsets.only(right: 5.w),
          child: Text(
            label,
            style: lfTextStyle(
              sp: 16.sp,
              fontFamily: fontMedium,
            ),
          ),
        ),
        Expanded(
          child: Text(
            value,
            textAlign: TextAlign.right,
            style: lfTextStyle(
              sp: 16.sp,
              fontFamily: fontRegular,
            ),
            overflow: TextOverflow.ellipsis,
          ),
        )
      ],
    ),
  );
}
